package cate.common.table.task.functasks;

import cate.common.table.ESheet;

import java.util.ArrayList;
import java.util.List;

public class FuncOpenTaskSheet extends ESheet<FuncOpenTaskRow> {
    @Override
    public String getSheetName() {
        return "引导任务";
    }

    public List<FuncOpenTaskRow> listByTaskId(int tid) {
        List<FuncOpenTaskRow> rowList = new ArrayList<>();
        for (FuncOpenTaskRow row : list) {
            if (row.taskId == tid) {
                rowList.add(row);
            }
        }
        return rowList;
    }

    public FuncOpenTaskRow rowByFuncOrder(int funcId, int orderId) {
        for (FuncOpenTaskRow row : list) {
            if (row.funcId == funcId && orderId == row.orderId) {
                return row;
            }
        }
        return null;
    }

    public List<Integer> allFuncIds() {
        List<Integer> funcIds = new ArrayList<>();
        list.stream().mapToInt(row -> row.funcId).distinct().forEach(funcIds::add);
        return funcIds;
    }
}
